import React from 'react'
import { renderToString } from 'react-dom/server'
import { Provider } from 'react-redux'
import { Router, Route, hashHistory } from 'react-router'
import structureStore from '../../store/createStore'

import ChouJiang from './components/choujiang.jsx'
import reducer from './modules/choujiang'

const routeNodes = (params, initState) => {
  let store = structureStore(params, initState, {
    params: () => params,
    layoutState: reducer
  })

  if (params.renderType === 'client') {
    return (
      <Provider store={store}>
        <Router history={hashHistory} >
          <Route path='/' component={ChouJiang} />
        </Router>
      </Provider>
    )
  } else {
    return ''
  }
}

export default routeNodes
